-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow a State to set a value in Credentials for subsequent states #145
Conversation
4023bcc
to
438179e
Compare
2f11e28
to
0bb77ee
Compare
4b2e0b8
to
db9aece
Compare
db9aece
to
af9936c
Compare
Checked commits agrare/floe@673377a~...af9936c with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
"username.$": "$.username", | ||
"password.$": "$.password" | ||
}, | ||
"ResultPath": "$.Credentials", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to state where in the credentials hash this will go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary since the ResultSelector
has "bearer_token.$": "$.echo"
which means that bearer_token
will be set to Credentials
.
If I did "ResultPath": "$Credentials.bearer_token"
this would end up looking like "Credentials": {"bearer_token": {"bearer_token": "abcd"}}
(and if I didn't have the ResultSelector
it would look like "Credentials": {"bearer_token": {"echo": "abcd"}}
)
bundle exec ruby exe/floe --workflow my-workflow.asl --credentials='{"username": "user", "password": "pass"}' | ||
``` | ||
|
||
```json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use asl here
```json | |
asl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get it, but I actually think the json markup actually renders nicer
{
"StartAt": "Login",
"States": {
"Login": {
"Type": "Task",
"Resource": "docker://login:latest",
"Credentials": {
"username.$": "$.username",
"password.$": "$.password"
},
"ResultPath": "$.Credentials",
"Next": "DoSomething"
},
"DoSomething": {
"Type": "Task",
"Resource": "docker://do-something:latest",
"Credentials": {
"token.$": "$.bearer_token"
},
"End": true
}
}
}
{
"StartAt": "Login",
"States": {
"Login": {
"Type": "Task",
"Resource": "docker://login:latest",
"Credentials": {
"username.$": "$.username",
"password.$": "$.password"
},
"ResultPath": "$.Credentials",
"Next": "DoSomething"
},
"DoSomething": {
"Type": "Task",
"Resource": "docker://do-something:latest",
"Credentials": {
"token.$": "$.bearer_token"
},
"End": true
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asl
doesn't differentiate between keys and values, and doesn't even markup the boolean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fryguy do you still want to do the asl
tag even though I think it is objectively worse?
the
ResultPath
parameter controls where the output of a state is stored. This adds the option to store the results in the workflowCredentials
hash allowing the value to be referenced by future states.This can be used by the
Task
andPass
states.Examples:
Say we have a task which logs into a service with a username/password and returns the bearer token:
floe --credentials '{"username": "foo", "password": "bar"}' ...
You can also use
ResultPath
to set nested values, e.g.:And then access it like:
If the output of the container doesn't match exactly what you want to set in the Credentials payload you can use the
ResultSelector
to manipulate it, say the output is in'{"results": "token"}'
:You can also use
Pass
states to manipulate the output and set a credential valueIf you don't have a static
Result
thePass
state works on Input so you could use Pass to send Input to Credentials. I don't think this is going to be particularly useful but I wanted to keep the behavior ofResultPath
consistent across states.